<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
  <title>CGU - JSON - fromJSON</title>
  <link rel="stylesheet" type="text/css" href="main.css" />
</head>

<body>

<div id="head">
  <div id="title">
    <h1>CGU</h1>&nbsp;&nbsp;<h2>Common &amp; General Use JavaScript</h2>
  </div>
</div>

<div id="foot">
  <div id="copy">
    <span>&copy; 2008 CGU</span>
  </div>
</div>

<div id="body">
  <div id="nav">
    <div class="pad">
      
      <div class="navlist">
        <h3>CGU</h3>
        <ul>
          <li><a href="index.html">Docs Home</a></li>
          <li><a href="functions.html">Functions</a></li>
        </ul>
      </div>
      
      <div class="navlist">
        <h3>JSON</h3>
        <ul>
          <li><a href="function.evalJSON.html">evalJSON</a></li>
          <li class="active"><a href="function.fromJSON.html">fromJSON</a></li>
          <li><a href="function.toJSON.html">toJSON</a></li>
        </ul>
      </div>
      
      <div class="navlist">
        <h3>Utilities</h3>
        <ul>
          <li><a href="utility.Cookie.html">Cookie</a></li>
          <li><a href="utility.Crypto.html">Crypto</a></li>
          <li><a href="utility.JSON.html">JSON</a></li>
          <li><a href="utility.Query.html">Query</a></li>
          <li><a href="utility.Time.html">Time</a></li>
          <li><a href="utility.Type.html">Type</a></li>
        </ul>
      </div>
      
    </div>
  </div>
  
  <div id="docs">
    <div class="pad">
      <div id="content">
<!-- Start: Content -->
      
      <h1>JSON</h1>
      
      <hr />
      
      <h2>fromJSON</h2>
      
      <blockquote>
        <p>A <b><i>more-secure</i></b> JSON interpreter.</p>
      </blockquote>
      
      <hr />
      
      <h3>Syntax</h3>
      
      <blockquote>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">fromJSON</span><span class="pun">(</span><span class="pln">json </span><span class="pun">[,</span><span class="pln"> strict</span><span class="pun">])</span></code></pre>
        
        <blockquote>
          <p><code><b>json</b> &lt;String&gt;</code>: A JSON-formatted string.</p>
          <p><code><b>strict</b> &lt;Boolean&gt;</code>: Only allow <a href="http://json.org">JSON.org</a> specified JSON strings.</p>
          <blockquote>
            <p>Will not convert date strings (<code>"0000-00-00T00:00:00Z"</code>) to Date Objects.</p>
            <p>Will not recognize <code>undefined</code> keyword.</p>
            <p>Will not accept octal or hexadecimal number literals.</p>
            <p>Will not accept object keys that are not string-formatted.</p>
            <p>Will not accept single-quoted strings or hex encodings (<code>"\xFF"</code>).</p>
        </blockquote>
      </blockquote>
      
      <h3>Return</h3>
      
      <blockquote>
        <p><code>&lt;Mixed&gt;</code>: Actual type will depend on the JSON-string being parsed.</p>
        <blockquote>
          <p><code>&lt;SyntaxError&gt;</code>: <code>json</code> string is malformed. <i>(thrown)</i></p>
        </blockquote>
      </blockquote>
      
      <hr />
      
      <h3>Example</h3>
      
      <blockquote>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">fromJSON</span><span class="pun">(</span><span class="str">'24'</span><span class="pun">);</span><span class="pln"> &nbsp; &nbsp; &nbsp;</span><span class="com">//=&gt; 24</span></code></pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">fromJSON</span><span class="pun">(</span><span class="str">'[2, 4]'</span><span class="pun">);</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; [2, 4]</span></code></pre>
        <pre>&nbsp;</pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">fromJSON</span><span class="pun">(</span><span class="str">'{foo: "bar"}'</span><span class="pun">);</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="com">//=&gt; {foo: "bar"}</span></code></pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">fromJSON</span><span class="pun">(</span><span class="str">'{foo: "bar"}'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">);</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; throw SyntaxError</span></code></pre>
        <pre>&nbsp;</pre>
        <pre class="prettify"><code><span class="pln">CGU</span><span class="pun">.</span><span class="pln">fromJSON</span><span class="pun">(</span><span class="str">'(function(){/*...*/})()'</span><span class="pun">);</span><span class="pln"> &nbsp;</span><span class="com">//=&gt; throw SyntaxError</span></code></pre>
      </blockquote>
      
      <hr />
      
<!-- Final: Content -->
      </div>
    </div>
  </div>
</div>

  <script type="text/javascript" src="main.js"></script>
</body>

</html>
